#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>

struct slab_test {
    unsigned long index;
    unsigned long offset;
    char *name;
};

/* 创建slab 缓存结构 和 slab使用对象 */
extern struct kmem_cache *slab_cachep;
extern struct slab_test *slab_object;

static int __init slab_free_demo_init(void)
{
    if (slab_object) 
    {
        printk("%s INDEX: %#lx\n", __func__, slab_object->index);
        kmem_cache_free(slab_cachep, slab_object );
    }

    kmem_cache_destroy(slab_cachep);
    return 0;
}

static void __exit slab_free_demo_exit(void)
{
    printk("slab_free_demo_exit \r\n");
}


module_init(slab_free_demo_init);
module_exit(slab_free_demo_exit);
MODULE_LICENSE("GPL");
